const path = require('path');
const fs = require('fs');
const routerDirPath = path.resolve(__dirname, '../routes');

const filePaths = fs.readdirSync(routerDirPath).map(fileName => {
  return path.resolve(routerDirPath, fileName);
});

module.exports = function (app) {
  filePaths.forEach(filePath => {
    const router = require(filePath);
    app.use(router.routes(), router.allowedMethods());
  });
};
